<template>
  <el-dialog :close-on-click-modal="false" :title="title" :visible.sync="dialogFormVisible" width="65vw" @close="close"
    :append-to-body="true">
    <el-form ref="form" :model="form" :rules="rules" label-width="100px">
      <el-row :gutter="10">
        <el-col :span="8">
          <el-form-item label="库房代码">
            <el-input v-model.trim="form.email" autocomplete="off"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="库房代码">
            <el-input v-model.trim="form.email" autocomplete="off"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="close">取 消</el-button>
      <el-button type="primary" @click="save">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { doEdit } from '@/api/userManagement'
import { queryKucunmxByid, updateKunmcSl } from '@/api/kucun'
export default {
  name: 'WarehouseManagement',
  data() {
    return {
      form: {},
      rules: {
      },
      title: '',
      dialogFormVisible: false,
    }
  },
  created() { },
  methods: {
    async showEdit(row) {
      if (!row) {
        this.title = '新增'
      } else {
        this.title = '编辑'
        let { data } = await queryKucunmxByid({ id: row.id })
        // console.log(data);
        // this.form = Object.assign({}, row)
      }
      this.dialogFormVisible = true
    },
    close() {
      this.$refs['form'].resetFields()
      this.form = this.$options.data().form
      this.dialogFormVisible = false
    },
    save() {
      this.$refs['form'].validate(async (valid) => {
        if (valid) {
          const { msg } = await updateKunmcSl(this.form)
          this.$baseMessage(msg, 'success')
          this.$emit('fetch-data')
          this.close()
        } else {
          return false
        }
      })
    },
  },
}
</script>
<style lang="scss" scoped>
.el-select--small {
  width: 100%;
}
</style>